package org.dzq.designmode.strategy;

/**
 * @ClassName: MemberContext
 * @Package: org.dzq.designmode.strategy
 * @author: 越
 * @date: 2023/6/14 20:20
 * @Description: 上下文对象
 */
public class MemberContext {

    private MemberStrategy primaryMemberStrategy;
    private MemberStrategy intermediateMemberStrategy;
    private MemberStrategy advanceMemberStrategy;

    public MemberContext(){
        this.primaryMemberStrategy = new PrimaryMemberStrategy();
        this.intermediateMemberStrategy = new IntermediateMemberStrategy();
        this.advanceMemberStrategy = new AdvanceMemberStrategy();
    }

    public double getCost(double price,int num,String userType){
        double cost = 0;
        if("primary".equals(userType)){
            cost = primaryMemberStrategy.calculateCost(price,num);
        }else if ("intermediate".equals(userType)){
            cost = intermediateMemberStrategy.calculateCost(price,num);
        }else if ("advance".equals(userType)){
            cost = advanceMemberStrategy.calculateCost(price,num);
        }
        return cost;
    }
}
